# name : dplyr::group row_number in the group, index as new variable
# key : group.row_number
# key : dplyr.group.row_number
# key : row_number.group
# contributor: Shuguang Sun
# --
group_by(${1:id}) |>
arrange(${2:index}, .by_group = TRUE) |>
mutate(${3:n} = row_number()) |>
ungroup()